package com.example.recyclerviewlearn;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.animation.ValueAnimator;
import android.os.Bundle;
import android.util.Log;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;

import java.util.ArrayList;
import java.util.List;

public class MainActivity_grid extends AppCompatActivity {
    private static final String TAG = "MainActivity_grid";

    RecyclerView mRecyclerView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_grid);
        mRecyclerView = findViewById(R.id.recyclerView);
        MyAdapter myAdapter = new MyAdapter(getApplicationContext(), initData());
        GridLayoutManager gridLayoutManager = new GridLayoutManager(getApplicationContext(), 2);
        mRecyclerView.setLayoutManager(gridLayoutManager);
        mRecyclerView.setAdapter(myAdapter);

        ValueAnimator valueAnimator = ValueAnimator.ofFloat(100F, 160F);
        valueAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
        valueAnimator.setDuration(200);
        valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                Log.i(TAG, "onAnimationUpdate: " + animation.getAnimatedValue());
            }
        });
        valueAnimator.start();
    }

    //初始化数据
    private List<String> initData() {
        int size = 60;
        List<String> myData = new ArrayList<>(size);
        for (int i = 0; i < size; i++) {
            myData.add("str: " + i);
        }
        return myData;
    }

    public class CustomizeLinearInterpolator implements Interpolator {

        @Override
        public float getInterpolation(float input) {
            Log.i(TAG, "getInterpolation: input" + input);
            return input;
        }
    }
}